package edu.java.ishop.services;

import java.util.List;

import javax.inject.Inject;
import javax.inject.Named;

import org.springframework.beans.factory.annotation.Qualifier;

import edu.java.ishop.dao.ProductCategoryDao;
import edu.java.ishop.dao.ProductDao;
import edu.java.ishop.model.Product;
import edu.java.ishop.model.ProductCategory;
@Named
public class ProductService {
	@Qualifier("databaseProductDao")
	@Inject
	private ProductDao dao;

	@Qualifier("databaseCategoryDao")
	@Inject
	private ProductCategoryDao categoryDao;
	
	public ProductService() {
	}

	public void setDao(ProductDao dao) {
		this.dao = dao;
	}

	public void setCategoryDao(ProductCategoryDao categoryDao) {
		this.categoryDao = categoryDao;
	}

	public List<Product> getAll() {
		return dao.getAll();
	}

	public List<ProductCategory> getCategories() {
		return categoryDao.getAll();
	}

	public boolean saveProduct(Product p) {
		return dao.save(p);
	}

	public void deleteProduct(long id) {
		dao.delete(id);
	}
	public void update(Product product){
		dao.update(product);
	}
}
